package com.openNetty.server.timertask;

import com.openNetty.common.system.LoggerUtil;
import com.openNetty.common.utils.FileTransUtil;
import com.openNetty.server.nettyserver.Global;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import static com.openNetty.common.bean.MainContents.ROOT;

/**
 * @version 1.0.0
 * @Author zhenggm
 */
public class CleanNodeFileTask implements Job {

    private static LoggerUtil logger = LoggerUtil.getLogger(CleanNodeFileTask.class);

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.debug("定时清理文件夹任务启动");
        String path = Global.properties.getProperty(ROOT);
        if (FileTransUtil.delAllFile(path)) {
            logger.debug("清理加密文件夹成功，任务结束");
        } else {
            logger.debug("文件夹不存在，无需清理");
        }
    }
}
